home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT8 / PG0808.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  6.4 KB  |  136 lines

  1. ;***********************************************************************
  2. ;
  3. ;  Program PG0808 ( Chapter 8 )
  4. ;
  5. ;  The demo program for working with the cursor (low level)
  6. ;
  7. ;  Author:  A.I.Sopin      VSU,     Voronezh, 1992
  8. ;
  9. ;
  10. ;  This program uses the register technique for controlling the cursor
  11. ;  Following video registers are used:
  12. ;
  13. ;                       3D4h - CRTC  Address Register
  14. ;                       3D5h - Cursor Start Register (Index  0Ah)
  15. ;
  16. ;
  17. ;  External Subroutines:  COLOR, VIDTYP, PUTSTR
  18. ;
  19. ;***********************************************************************
  20. .MODEL  SMALL
  21. EXTRN   COLOR : FAR, VIDTYP : FAR, PUTSTR : FAR
  22. .STACK
  23. BEL     EQU     7       ;  Bell
  24. LF      EQU     10      ;  Line Feed
  25. CR      EQU     13      ;  Carriage Return
  26.  
  27. ;----------------------------------------------------------
  28. .DATA
  29. STRING  DB      80 dup ('E'), 0
  30. TEXT0   DB      CR, LF
  31.     DB      ' The cursor controlling demo program.  Press any key...'
  32.     DB      BEL, '$'
  33. TEXT1   DB      CR, LF
  34.     DB      ' Video Type = '
  35. VTypeS  DB      'X'
  36.     DB      '   MODE = '
  37. VModeS  DB      'X'
  38.     DB      CR,LF
  39.     DB      ' This is the Hardware Cursor.          Press any key...', '$'
  40. TEXT2   DB      ' Cursor is turned  Off.                Press any key...', 0
  41. TEXT3   DB      CR, LF
  42.     DB      ' This is the New Cursor.               Press any key...', BEL, '$'
  43. VMODE   DB      0                       ;  The video mode
  44. ADAPTER DB      0                       ;  The videoadapter type
  45. VIDBUF  DW      0                       ;  The address of videobuffer
  46. ;----------------------------------------------------------
  47. .CODE
  48. .Startup
  49. Start:
  50.     mov     ah,0Fh                  ;  function 0Fh - get video mode
  51.     int     10h                     ;  BIOS video service call
  52.     mov     VMODE,al                ;  save original video mode
  53.     mov     ah,0                    ;  function 00h - set video mode
  54.     mov     al,3                    ;  video mode 3 - COLOR 80x25
  55.     int     10h                     ;  BIOS video service call
  56.     mov     ah,1Fh                  ;  white characters on blue background
  57.     mov     ch,1                    ;  starting line 1
  58.     mov     dh,25                   ;  last line 25
  59.     Call    Color                   ;  fill screen with prescribed color
  60. ;  Output initial message
  61.     lea     dx,TEXT0                ;  address of text to be output
  62.     mov     ah,9                    ;  function 09h - output text string
  63.     int     21h                     ;  DOS service call
  64.     xor     ah,ah                   ;  function 00h - get key
  65.     int     16h                     ;  BIOS keyboard service call
  66. ;  determine and report the video adapter type and video mode
  67.     Call    VIDTYP                  ;  determine video adapter type
  68.     mov     ADAPTER,al              ;  save  video adapter type
  69.     mov     VIDBUF,dx               ;  segment address of video buffer
  70.     mov     VTypeS,al               ;  Video Adapter Type
  71.     or      VTypeS,30h              ;  Bin ---> ASCII
  72.     mov     ah,0Fh                  ;  function 0Fh - get video mode
  73.     int     10h                     ;  BIOS video service call
  74.     mov     VModeS,al               ;  Video Mode
  75.     or      VModeS,30h              ;  Bin ---> ASCII
  76.     lea     dx,TEXT1                ;  address of text to be output
  77.     mov     ah,9                    ;  function 09h - output text string
  78.     int     21h                     ;  DOS service call
  79.     xor     ah,ah                   ;  function 00h - get key
  80.     int     16h                     ;  BIOS keyboard service call
  81. ;-------------------------------------------------------------------
  82. ;  Swith the cursor OFF (6845 registers are used  for  MDA, CGA, VGA)
  83.     cmp     ADAPTER,3               ;  EGA ?
  84.     je      EGAOFF                  ;
  85.     xor     ax,ax                   ;  Segment for  BIOS  Area
  86.     mov     es,ax                   ;
  87.     mov     dx,es:[463h]            ;  CRTC  Address Register
  88.     mov     al,10                   ;  Index =10 (Cursor Start)
  89.     out     dx,al                   ;  Select Index
  90.     inc     dx                      ;  3D5h - Cursor Start Register
  91.     mov     al,20h                  ;  Cursor is turned off
  92.     out     dx,al                   ;  Execute
  93.     jmp     short  MSG_OFF          ;
  94. ;  Switch the cursor OFF (BIOS  INT 10h, EGA  only)
  95. EGAOFF: xor     bh,bh                   ;  Video Page Number
  96.     mov     ah,3                    ;  Get Cursor
  97.     int     10h                     ;  Call  BIOS  Service
  98.     mov     ah,1                    ;  Set Cursor
  99.     or      ch,30h                  ;
  100.     int     10h                     ;  Cursor is turned off
  101. ;  Output message "Cursor turned OFF"
  102. MSG_OFF:lea     si,TEXT2                ;  address of text to be output
  103.     mov     ah,1Fh                  ;  white characters on blue background
  104.     xor     bh,bh                   ;  video page 0
  105.     mov     dx,0400h                ;  DH - row; DL - column
  106.     mov     cx,80                   ;  max length of string
  107.     mov     bl,ADAPTER              ;
  108.     mov     es,VIDBUF               ;  segment address of video buffer
  109.     Call    PUTSTR                  ;  output ASCIIZ string
  110.     xor     ah,ah                   ;  function 00h - get key
  111.     int     16h                     ;  BIOS keyboard service call
  112. ;  Set up the new cursor of increased size (for  MDA, CGA, EGA, VGA)
  113.     xor     ax,ax                   ;
  114.     mov     es,ax                   ;
  115.     mov     dx,es:[463h]            ;  CRTC  Address Register
  116.     mov     al,10                   ;  Index =10 (Cursor Start)
  117.     out     dx,al                   ;  Select Index
  118.     inc     dx                      ;  3D5h -Cursor Start Register
  119.     mov     al,1                    ;  Cursor Start Line
  120.     out     dx,al                   ;  Execute
  121. ;-------------------------------------------------------------------
  122. ;  Display the new cursor of increased size
  123.     lea     dx,TEXT3                ;  address of text to be output
  124.     mov     ah,9                    ;  function 09h - output text string
  125.     int     21h                     ;  DOS service call
  126.     xor     ah,ah                   ;  function 00h - get key
  127.     int     16h                     ;  BIOS keyboard service call
  128. ;-------------------------------------------------------------------
  129. ;  Finish the program and return to MS-DOS
  130. Exit:   mov     al,VMODE                ;  AL - original video mode
  131.     xor     ah,ah                   ;  function 00h - set video mode
  132.     int     10h                     ;  BIOS video service call
  133.     mov     ax,4C00h                ;  Return Code =0
  134.     int     21h                     ;  BIOS video service call
  135.     END
  136.